﻿using System;
using DevExpress.Web.ASPxRibbon;

namespace Bonesystem.Extensions
{
    public static class RibbonExtensions
    {
        public static T CreateButtonItem<T>(string name, string text, string iconId) where T : RibbonButtonItem
        {
            return CreateButtonItem<T>(name, text, RibbonItemSize.Small, iconId);
        }

        public static T CreateButtonItem<T>(string name, string text, RibbonItemSize size, string iconId) where T : RibbonButtonItem
        {
            var item = Activator.CreateInstance<T>();
            item.Name = name;
            item.Text = text;
            item.Size = size;
            if (size == RibbonItemSize.Large)
                item.LargeImage.IconID = iconId;
            else
                item.SmallImage.IconID = iconId;
            return item;
        }

    }
}